Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test not to interpret strings as lists #43

Closed

Conversation

cjerdonek
Copy link
Contributor

In Python, for example (as in many other languages undoubtedly), strings are sequence types that share many of the same properties as lists and other iterator types:

http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange

It would be good to add a test for this. One does not seem to exist yet in the spec (incidental or not).

…s lists.

In Python, for example, strings are sequence types that share many of the
same properties as lists and other iterator types:

  http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange

A test for this does not yet exist in the spec (incidental or not).
@bobthecow
Copy link
Member

In Ruby 1.8.x, strings are Enumerable by line, so treating 123 as a list would still pass this test case. If you change the value to 123\n456 that should cover this case as well.

cjerdonek added a commit to cjerdonek/mustache-spec that referenced this pull request May 3, 2012
@jgonggrijp
Copy link
Member

Nowadays, the following test is included in the spec, which subtly implies that a string should not be iterated as a list:

spec/specs/sections.yml

Lines 68 to 75 in 5d3b58e

- name: Variable test
desc: |
Non-false sections have their value at the top of context,
accessible as {{.}} or through the parent context. This gives
a simple way to display content conditionally if a variable exists.
data: { foo: "bar" }
template: '"{{#foo}}{{.}} is {{foo}}{{/foo}}"'
expected: '"bar is bar"'

Hence, the proposed addition is not needed. Closing, discussion still welcome.

@jgonggrijp jgonggrijp closed this Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants